//  https://mall.360.cn/skin/container

// const { data } = require("jquery")


/* 
二级菜单
  => https://mall.360.cn/h5/getSecondaryCategory
*/


// 二级菜单
// 家庭安防
const listMenu1 = document.querySelector('.nav > .contain > .categroy > .list > .list_item1 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '30'
}
// console.log(listMenu1)
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  console.log(res)
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu1.innerHTML = str;
})

// 安全路由
const listMenu2 = document.querySelector('.nav > .contain > .categroy > .list > .list_item2 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '31'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu2.innerHTML = str;
})

// 智能手表
const listMenu3 = document.querySelector('.nav > .contain > .categroy > .list > .list_item3 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '32'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu3.innerHTML = str;
})

// 汽车用品
const listMenu4 = document.querySelector('.nav > .contain > .categroy > .list > .list_item4 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '33'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu4.innerHTML = str;
})

// 扫地机器人
const listMenu5 = document.querySelector('.nav > .contain > .categroy > .list > .list_item5 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '34'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu5.innerHTML = str;
})

// 影音生活
const listMenu6 = document.querySelector('.nav > .contain > .categroy > .list > .list_item6 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '35'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu6.innerHTML = str;
})

// 生态产品
const listMenu7 = document.querySelector('.nav > .contain > .categroy > .list > .list_item7 > .menu > .menu-box')
var info= {
  type: 'pc_index_category',
  id : '36'
}
$.ajax({ 
  url: '/hs', 
  dataType: 'json',
  data: info
}).then(res => {
  let str = ``
  res.data.secondary.forEach(item => {
    str += `
    <div class="menu-item" href="">
        <img src="${item.pic}" alt="">
        <p>${item.name}</p>
    </div>
    `
  })
  listMenu7.innerHTML = str;
})


// 页面主要内容区
// 家庭安防
const listBox1 = document.querySelector('.main > .box_1 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {
  // console.log(res)
  let str = `
  <li class="item_1">
      <a href="">
          <img src="https://p5.ssl.qhimg.com/t01b3f0ea7d9f0b5000.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[4].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox1.innerHTML = str;
})



// 安全路由
const listBox2 = document.querySelector('.main > .box_2 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {

  let str = `
  <li class="item_1">
      <a href="">
        <img src="https://p2.ssl.qhimg.com/t01450436bc349ddae5.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[6].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox2.innerHTML = str;
})


// 行车安全
const listBox3 = document.querySelector('.main > .box_3 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {

  let str = `
  <li class="item_1">
      <a href="">
        <img src="https://p4.ssl.qhimg.com/t0133be414b0dd21744.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[8].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox3.innerHTML = str;
})

// 扫地机器人
const listBox4 = document.querySelector('.main > .box_4 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {

  let str = `
  <li class="item_1">
      <a href="">
        <img src="https://p2.ssl.qhimg.com/t010270e51d5a815568.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[10].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox4.innerHTML = str;
})

// 智能守护
const listBox5 = document.querySelector('.main > .box_5 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {

  let str = `
  <li class="item_1">
      <a href="">
        <img src="https://p3.ssl.qhimg.com/t0118faff228911ab53.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[12].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox5.innerHTML = str;
})

// 生态互联
const listBox6 = document.querySelector('.main > .box_6 > .body')

$.ajax({ url: '/fc', dataType: 'json', }).then(res => {

  let str = `
  <li class="item_1">
      <a href="">
        <img src="https://p5.ssl.qhimg.com/t01b1999ef9da609b19.webp" alt="">
      </a>
  </li>
  `
  res.data.floors[14].data.list.forEach(item => {
    str += `
    <li class="item_2">
    <a href="./detail.html">
        <p class="tatle">${item.label}</p>
        <img src="${item.img}" alt="">
        <p class="name">${item.title}</p>
        <p class="desc">${item.desc}</p>
        <p class="price"><i>${item.currentPrice}</i><span>${item.originPrice}</span></p>
    </a></li>
    `
  })
  listBox6.innerHTML = str;
})


// 更多商品
// https://search.mall.360.cn/search/latest
// https://search.mall.360.cn/search/latest
// https://search.mall.360.cn/search/latest?callback=jQuery110209617467834611375_1641647582122&q=*&size=20&page=1&_=1641647582125
const moreBox = document.querySelector('.main > .more > .body')
$.ajax({ url: '/mode', dataType: 'json', }).then(res => {
// console.log(res)
  let str = ``
  res.data.list.forEach(item => {
    str += `
    <li>
    <a href="./detail.html">
        <img src="${item.img}" alt="">
        <p class="tatle">${item.title}</p>
        <p class="price"><span>${item.price}</span></p>
        <p class="tagString"><span>${item.tagString}</span></p>
    </a></li>
    `
  })
  moreBox.innerHTML = str;
})
